 
/****** Object:  Table [dbo].[T_BMES_NGBatch_SN]    Script Date: 2023/7/28 15:19:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_BMES_NGBatch_SN](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[SN] [varchar](50) NULL,
	[WorkOrderNo] [varchar](50) NULL,
	[ParentBatchNo] [varchar](50) NULL,
	[BatchNo] [varchar](50) NULL,
	[TestProduceId] [varchar](50) NULL,
	[MachineNum] [varchar](50) NULL,
	[BatchType] [int] NULL,
	[CheckStatus] [int] NULL,
	[CheckResult] [int] NULL,
	[ServerTime] [datetime] NULL,
	[CheckTime] [datetime] NULL,
 CONSTRAINT [PK_T_BMES_NGBatch_SN] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_SN] ON [dbo].[T_BMES_NGBatch_SN]
(
	[SN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO

 
/****** Object:  Table [dbo].[T_BMESBatchRecord]    Script Date: 2023/7/28 15:19:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_BMESBatchRecord](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[BatchNo] [varchar](50) NULL,
	[ParentBatchNo] [varchar](50) NULL,
	[WorkOrderNo] [varchar](50) NULL,
	[MaterialId] [varchar](50) NULL,
	[BatchType] [int] NULL,
	[ModeType] [int] NULL,
	[PlanQty] [int] NULL,
	[RealQty] [int] NULL,
	[OKQty] [int] NULL,
	[NGQty] [int] NULL,
	[PendingQty] [int] NULL,
	[TableName] [varchar](50) NULL,
	[Line] [varchar](20) NULL,
	[ProcedureId] [varchar](20) NULL,
	[MachineNum] [varchar](50) NULL,
	[BatchStatus] [int] NULL,
	[StartTime] [datetime] NULL,
	[ServerTime] [datetime] NULL,
 CONSTRAINT [PK_T_BMESBatchRecord] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[T_BMESBatchTest]    Script Date: 2023/7/28 15:19:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_BMESBatchTest](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[BatchNo] [varchar](50) NULL,
	[MaterialId] [varchar](50) NULL,
	[TestProcedureId] [varchar](50) NULL,
	[WorkOrderNo] [varchar](50) NULL,
	[BatchType] [int] NULL,
	[ModeType] [int] NULL,
	[PlanQty] [int] NULL,
	[RealQty] [int] NULL,
	[Line] [varchar](50) NULL,
	[MachineNum] [varchar](50) NULL,
	[BatchStatus] [int] NULL,
	[ServerTime] [datetime] NULL,
 CONSTRAINT [PK_T_BMESBatchTest] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[T_BMESBatchTestDeal]    Script Date: 2023/7/28 15:19:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_BMESBatchTestDeal](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[BatchNo] [varchar](50) NULL,
	[ParentBatchNo] [varchar](50) NULL,
	[MaterialId] [varchar](50) NULL,
	[TestProcedureId] [varchar](50) NULL,
	[WorkOrderNo] [varchar](50) NULL,
	[BatchType] [int] NULL,
	[PlanQty] [int] NULL,
	[RealQty] [int] NULL,
	[Line] [varchar](50) NULL,
	[BatchStatus] [int] NULL,
	[ServerTime] [datetime] NULL,
 CONSTRAINT [PK_T_BMESBatchTestDeal] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[T_BMESBatchTrace]    Script Date: 2023/7/28 15:19:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_BMESBatchTrace](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[BatchNo] [varchar](50) NULL,
	[MaterialId] [varchar](50) NULL,
	[TableName] [varchar](50) NULL,
	[WorkOrderNo] [varchar](50) NULL,
	[BatchType] [int] NULL,
	[ModeType] [int] NULL,
	[PlanQty] [int] NULL,
	[RealQty] [int] NULL,
	[BatchStatus] [int] NULL,
	[Line] [varchar](50) NULL,
	[ServerTime] [datetime] NULL,
 CONSTRAINT [PK_T_BMESBatchTrace] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[T_BMESWorkOrder]    Script Date: 2023/7/28 15:19:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_BMESWorkOrder](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[work_order_no] [varchar](50) NULL,
	[material_id] [varchar](50) NOT NULL,
	[sfc_station_code] [varchar](50) NULL,
	[table_name] [varchar](50) NULL,
	[line] [varchar](50) NULL,
	[work_status] [int] NULL,
	[plan_start_time] [datetime] NULL,
	[plan_end_time] [datetime] NULL,
	[plan_product_qty] [int] NULL,
	[actual_start_time] [datetime] NULL,
	[actual_end_time] [datetime] NULL,
	[ok_qty] [int] NULL,
	[ng_qty] [int] NULL,
	[status] [int] NOT NULL,
	[create_time] [datetime] NULL,
	[sap_order_type]  [int] NULL,
 CONSTRAINT [PK_ORD_WORK_ORDER] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[T_BMES_NGBatch_SN] ADD  CONSTRAINT [DF_T_BMES_NGBatch_SN_ServerTime]  DEFAULT (getdate()) FOR [ServerTime]
GO
ALTER TABLE [dbo].[T_BMESBatchRecord] ADD  CONSTRAINT [DF_T_BMESBatchRecord_ServerTime]  DEFAULT (getdate()) FOR [ServerTime]
GO
ALTER TABLE [dbo].[T_BMESBatchTest] ADD  CONSTRAINT [DF_T_BMESBatchTest_ServerTime]  DEFAULT (getdate()) FOR [ServerTime]
GO
ALTER TABLE [dbo].[T_BMESBatchTestDeal] ADD  CONSTRAINT [DF_T_BMESBatchTestDeal_ServerTime]  DEFAULT (getdate()) FOR [ServerTime]
GO
ALTER TABLE [dbo].[T_BMESBatchTrace] ADD  CONSTRAINT [DF_T_BMESBatchTrace_create_time]  DEFAULT (getdate()) FOR [ServerTime]
GO
ALTER TABLE [dbo].[T_BMESWorkOrder] ADD  CONSTRAINT [DF_T_BMESWorkOrder_create_time]  DEFAULT (getdate()) FOR [create_time]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批次号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace', @level2type=N'COLUMN',@level2name=N'BatchNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工单号id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace', @level2type=N'COLUMN',@level2name=N'WorkOrderNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批次类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace', @level2type=N'COLUMN',@level2name=N'BatchType'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批次数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace', @level2type=N'COLUMN',@level2name=N'PlanQty'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace', @level2type=N'COLUMN',@level2name=N'BatchStatus'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace', @level2type=N'COLUMN',@level2name=N'ServerTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批次表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESBatchTrace'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工单号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'work_order_no'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'物料id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'material_id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'工段' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'sfc_station_code'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'work_status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'计划开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'plan_start_time'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'计划结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'plan_end_time'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'计划生产数量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'plan_product_qty'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'actual_start_time'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'actual_end_time'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder', @level2type=N'COLUMN',@level2name=N'create_time'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产工单' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BMESWorkOrder'
GO
